home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1998 Macromedia, Inc. All rights reserved.
-
- //****************** Globals *******************
-
- function initGlobals() {
- PLUGIN_NAMES = new Array("Shockwave Flash","Shockwave for Director","LiveAudio",
- "Netscape Media Player","QuickTime Plug-In");
- }
-
- var PLUGIN_NAMES;
-
-
- //******************* BEHAVIOR FUNCTION **********************
-
- //Sends the browser to one URL if the plugin exists, otherwise
- //sends the browser to an alternate URL.
- //The function accepts the following arguments:
- // plugin - the *exact* name of the plugin as registered (ex: Shockwave Flash 2.0)
- // theURL - optional URL, often a filename, URL encoded. (ex: file.htm, http://www.x.com/y.htm)
- // altURL - required URL, often a filename, URL encoded. (ex: file.htm, http://www.x.com/y.htm)
- // IEGoesToURL - boolean. If true, Internet Explorer always goes to theURL. If false, altURL.
- //
- //Checks if the plugins array exists and the plugin is found, *or*
- //if flag is set, and MSIE browser for Win95/NT (ActiveX ok), then goes to theURL if nonempty.
- //else goes to altURL. Goes to a URL by setting the window.location property.
-
- function MM_checkPlugin(plugin, theURL, altURL, IEGoesToURL) { //v2.0
- if ((navigator.plugins && navigator.plugins[plugin]) || //if NS, or
- (IEGoesToURL && //if flag set, and MSIE browser for Win95/NT (ActiveX)
- navigator.appName.indexOf('Microsoft') != -1 &&
- navigator.appVersion.indexOf('Mac') == -1 &&
- navigator.appVersion.indexOf('3.1') == -1)) {
- if (theURL.length>2) window.location = theURL;
- } else {
- if (altURL.length>2) window.location = altURL;
- }
- document.MM_returnValue = false;
- }
-
-
- //******************* API **********************
-
-
- //Can be used with any tag and any event
-
- function canAcceptBehavior(){
- return true;
- }
-
-
-
- //Returns a Javascript function to be inserted in HTML head with script tags.
-
- function behaviorFunction() {
- return "MM_checkPlugin";
- }
-
-
-
- //Returns fn call to insert in HTML tag <TAG... onEvent='thisFn(arg)'>
- //Calls escQuotes to find embedded quotes and precede them with \
- //Calls escape to encode URLs
-
- function applyBehavior() {
- var pluginName, theURL, altURL, IEGoesToURL, theMenu;
-
- if (document.theForm.theRadio[0].checked) { //get URL from textfield or menu
- pluginName = document.theForm.menu.options[document.theForm.menu.selectedIndex].text;
- } else {
- pluginName = escQuotes(document.theForm.pluginName.value);
- }
-
- theURL = escape(document.theForm.theURL.value); //URL encode
- altURL = escape(document.theForm.altURL.value); //URL encode
- IEGoesToURL = document.theForm.IEGoesToURL.checked;
- if (pluginName && altURL) {
- return "MM_checkPlugin('"+pluginName+"','"+theURL+"','"+altURL+"',"+IEGoesToURL+")";
- } else {
- return MSG_NoPluginOrURL;
- }
- }
-
-
-
- //Returns a dummy function call to inform Dreamweaver the type of certain behavior
- //call arguments. This information is used by DW to fixup behavior args when the
- //document is moved or changed.
- //
- //It is passed an actual function call string generated by applyBehavior(), which
- //may have a variable list of arguments, and this should return a matching mask.
- //
- //The return values are:
- // URL : argument could be a file path, which DW will update during Save As...
- // NS4.0ref: arg is an object ref that may be changed by Convert Tables to Layers
- // IE4.0ref: arg is an object ref that may be changed by Convert Tables to Layers
- // other...: argument is ignored
-
- function identifyBehaviorArguments(fnCallStr) {
- var argArray;
-
- argArray = extractArgs(fnCallStr);
- if (argArray.length == 5) {
- return "other,URL,URL,other";
- } else {
- return "";
- }
- }
-
-
-
- //Passed the function call above, takes prior arguments and reloads the UI.
- //Removes any escape characters "\"
-
- function inspectBehavior(argStr){
- var i, plugIn, inMenu;
- var argArray = extractArgs(argStr);
-
- if (argArray.length == 5) {
-
- plugIn = unescQuotes(argArray[1]);
- document.theForm.theURL.value = unescape(argArray[2]); //URL decode
- document.theForm.altURL.value = unescape(argArray[3]); //URL decode
- document.theForm.IEGoesToURL.checked = eval(argArray[4]);
-
- inMenu = false;
- for (i=0; i<document.theForm.menu.options.length; i++) { //check if exists in menu
- if (document.theForm.menu.options[i].text == plugIn) {
- document.theForm.menu.selectedIndex = i;
- inMenu = true;
- break;
- }
- }
- if (!inMenu) {
- document.theForm.pluginName.value = plugIn;
- setRadio(1); //set radio
- }
- }
- }
-
-
-
- //**************** LOCAL FUNCTIONS ****************
-
-
- //Loads a preset list of some plugin names.
-
- function initializeUI() {
- initGlobals();
- for (i=0; i<PLUGIN_NAMES.length; i++)
- document.theForm.menu.options[i] = new Option(PLUGIN_NAMES[i]);
-
- document.theForm.theURL.focus(); //set focus on textbox
- document.theForm.theURL.select(); //set insertion point into textbox
- }
-
-
-
- //Passed a number, selects that radio.
-
- function setRadio(num) {
- document.theForm.theRadio[0].checked = (num==0)?true:false;
- document.theForm.theRadio[1].checked = (num==1)?true:false;
- }
-
-
-
- //**************** GENERIC FUNCTIONS ****************
-
- //function extractArgs(upStr){
- //function escQuotes(theStr){
- //function unescQuotes(theStr){
- //function browseFile(fieldToStoreURL){
-